const Taobao = require('../utils/TaoBao')
const serverConfig = require('../server.config')
const fs = require("fs");
let devInfo = serverConfig.getDeviceInfo(undefined, undefined, "IMEI")

Taobao.getRecommendList({material_id: '39313', devInfo}).then(res => {
    res.result_list.total = res.result_list.map_data.length
    try {
        if (fs.existsSync('./goods.json'))fs.rmSync('./goods.json')
        fs.appendFileSync('./goods.json', JSON.stringify(res), {encoding: 'utf8'})
        console.log('The "data to append" was appended to file!');
    } catch (err) {
        // Handle the error
        throw err
    }
}).catch(e => console.log(e))

Taobao.searchByKeyWord('最右',1,20,true,undefined).then(res => {
    res.result_list.total = res.result_list.map_data.length
    try {
        if (fs.existsSync('./searchByKeyword.json'))fs.rmSync('./searchByKeyword.json')
        fs.appendFileSync('./searchByKeyword.json', JSON.stringify(res), {encoding: 'utf8'})
        console.log('The "data to append" was appended to file!');
    } catch (err) {
        // Handle the error
        throw err
    }
}).catch(e => console.log(e))

// console.log(serverConfig.apiConfig.filter(item => item.name === '物料精选')[0].url)
